from fastapi import FastAPI
from starlette.staticfiles import StaticFiles
from starlette.responses import RedirectResponse
from routers.foodapi import router as food_router

try:
    app = FastAPI(title="Feri的Python一套Api接口",description="Feri的Python一套Api接口",version="0.0.1",
                  contact={"name": "Feri", "url": "https://github.com/Feri-Fu", "email": "feri@163.com"},)
    app.include_router(food_router)
except Exception as e:
    print(f"Error occurred: {e}")
    raise
# 静态文件
app.mount("/page", StaticFiles(directory="pages"), name="page")

@app.get("/")
async def root():
    # 重定向
    return RedirectResponse(url="page/index.html", status_code=303)


app.include_router(food_router)